<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
	<style type="text/css">
		.New_Button, .Edit_Button, .Delete_Button, .Update_Button, .Cancel_Button
	    {
	        font-size:11px;color:#1B3F91;font-family:Verdana;  
	        margin-right:5px;
	    }
	    .mini-radiobuttonlist-td
	    {
	    	height: 25px;
	    }
	    .asLabel .mini-textbox-border,
	    .asLabel .mini-textbox-input,
	    .asLabel .mini-buttonedit-border,
	    .asLabel .mini-buttonedit-input,
	    .asLabel .mini-textboxlist-border
	    {
	        border:0;background:none;cursor:default;
	    }
	    .asLabel .mini-buttonedit-button,
	    .asLabel .mini-textboxlist-close
	    {
	        display:none;
	    }
	    .asLabel .mini-textboxlist-item
	    {
	        padding-right:8px;
	    } 
	</style>
</head>
<body>
	<fieldset style="border:solid 1px #aaa;padding:3px;">
		<legend >客户电话</legend>
        <input name="callId" class="mini-hidden" />
        <div id="form1" style="padding-left:5px;padding-bottom:7px;">
            <div id="datagrid1" class="mini-datagrid" style="width:740px;height:auto;" showLoading="false" allowResize="false"
        		url="orders_find_tel_view.do"  idField="id" showPager="false">
		        <div property="columns">
		            <div field="phoneNum" width="20%" headerAlign="center" >号码
		                <input property="editor" name="phoneNum" class="mini-textbox" style="width:100%;" required="true"/>
		            </div>
		            <div type="comboboxcolumn" field="type" width="10%" headerAlign="center" >类型
		                <input property="editor" name="type" valueField="keyName" textField="keyValue" class="mini-combobox" style="width:100%;" url="dictionary_cm_key_val_view.do?typeName=CUSTOMER_PHONE_TYPE" required="true"/>                
		            </div>
		            <div type="comboboxcolumn" field="isMain" width="10%" headerAlign="center" >是否主要
		            	<input property="editor" name="isMain" class="mini-combobox" style="width:100%;" data="isMajor" required="true"/>
		            </div>
		            <div field="remarks" width="35%" headerAlign="center" allowSort="true">备注
		                <input property="editor" name="remarks" class="mini-textbox" style="width:100%;"/>
		            </div>                              
		        </div>
    		</div>
        </div>
    </fieldset>
    <form id="form2" method="post">
	    <fieldset style="border:solid 1px #aaa;padding:3px;">
	        <legend >基本信息</legend>
	        <div style="padding:10px;">
	        <input name="id" id="customer_id" class="mini-hidden" />
			    <table cellspacing="15px;" cellpadding="0px;">
			        <tr>
			            <td>姓名：</td>
			            <td style="width:250px;">    
			                <input name="name" style="width: 150px;" class="mini-textbox" enabled="false" required="true"/>
			            </td>
			            <td>性别：</td>
			            <td >                        
							<input name="sex" class="mini-radiobuttonlist" repeatItems="1" repeatLayout="table" repeatDirection="vertical" textField="keyValue" valueField="keyName"
			                	url="dictionary_cm_key_val_view.do?typeName=CUSTOMER_SEX_TYPE" enabled="false" onbeforeshowpopup="onbeforeshowpopup"/>
			            </td>
			        </tr>
			        <tr>
			            <td >出生日期：</td>
			            <td >    
			                <input name="birthDate" style="width: 150px;" class="mini-datepicker" enabled="false" emptyText="请选择日期"/>
			            </td>
			            <td>客户级别：</td>
			            <td >    
							<input name="customerLevel" style="width: 150px;" class="mini-combobox" valueField="keyName" textField="keyValue" enabled="false"
			                 	url="dictionary_cm_key_val_view.do?typeName=CUSTOMER_LEVEL_TYPE"/>
			            </td>
			        </tr>
			        <tr>
			        	<td>客户来源：</td>
			        	<td>
							<input name="customersSource" id="customers_source" style="width: 150px;" valueField="keyName" textField="keyValue" enabled="false" class="mini-combobox"
			        		 url="dictionary_cm_key_val_view.do?typeName=CUSTOMER_SOURCE_TYPE" />
			        	</td>
			        	<td>是否邮寄期刊：</td>
			        	<td>
							<input name="journal" style="width: 150px;" valueField="keyName" textField="keyValue" class="mini-combobox" enabled="false"
			        		 url="dictionary_cm_key_val_view.do?typeName=CUSTOMER_MAIL_TYPE"/>
			        	</td>
			        </tr>
			        <tr>
			        	<td>地址：</td>
			        	<td colspan="3">
			        		<input name="provinceId" id="province_val" class="mini-hidden"/>
			        		<input id="province" name="pName" class="mini-textbox" onfocus="focusP" enabled="false" emptyText="请选择省份"/>
			        		<input name="cityId" class="mini-hidden" id="city_val" />
			        		<input class="mini-textbox" name="cName" id="city" enabled="false" emptyText="请选择城市"/>
			        		<input name="districtId" id="district_val" class="mini-hidden"/>
			        		<input class="mini-textbox" name="dName" enabled="false" id="district" readOnly="true" emptyText="请选择区县"/>
			        		<span>邮编：</span>
			        		<input class="mini-textbox" name="zipCode" enabled="false" style="width: 85px;" />
			        	</td>
			        </tr>
			        <tr>
			        	<td>详细地址：</td>
			        	<td colspan="3">
			        		<input name="address" class="mini-textbox" enabled="false" style="width:400px;" />
			        	</td>
			        </tr>
			        <tr>
			        	<td>会员信息：</td>
			            <td colspan="3"> 
			            	<span>余额：</span>   
			                <input name="money" class="mini-textbox" enabled="false" style="width: 95px;"/>
			                <span>积分：</span>
			                <input name="integral" class="mini-textbox" enabled="false" style="width: 72px;"/>
			                <span>红包：</span>
			                <input name="redEnvelopes" class="mini-textbox" enabled="false" style="width: 72px;"/>
			            </td>
			        </tr>
			        <tr>
			            <td>推荐人：</td>
			            <td>
			            	<input name="recommended" enabled="false" style="width: 150px;" class="mini-textbox" />
			            </td>
			        </tr>
			        <tr>
			            <td >备注：</td>
			            <td colspan="3">
			                <input name="remarks" class="mini-textarea" enabled="false" style="width:400px;" />
			            </td>
			        </tr>
			    </table>
	        </div>
	    </fieldset>
	</form>
	<div id="win1" class="mini-window" allowDrag="false" showHeader="false" title="选择地址—省份" style="width: 300px;height: 150px;">
	</div>
	<div id="win2" class="mini-window" allowDrag="false" showHeader="false" title="选择地址—省份" style="width: 300px;height: 150px;">
	</div>
	<div id="win3" class="mini-window" allowDrag="false" showHeader="false" title="选择地址—省份" style="width: 300px;height: 150px;">
	</div>
</body>
</html>

<script type="text/javascript">
	mini.parse();
	var grid = mini.get("datagrid1");
	
	// 加载本地数据
	var isMajor = [{ id: 1, text: '是' }, { id: 0, text: '否'}];
 	
 	// 标准方法接口定义
 	var callId = mini.getbyName("callId");
	function SetData(data) {
		data = mini.clone(data);
		grid.load({customerId: data.cId});
		callId.setValue(data.cId);
		$.post("audit_customer_detail_view.do", {customerId: callId.getValue()}, function(data){
			if(null != data.customer) {
				form2.setData(data.customer);
			}
		}, "json");
	}
    
    var form1 = new mini.Form("#form1");
    
 	// 客户信息表单
    var form2 = new mini.Form("form2");
 	
 	// 弹出省份列表
 	var win1 = mini.get("win1");
 	var province = mini.get("province");
 	var provinceVal = mini.get("province_val");
 	function focusP(e) {
 		var el=e.sender.getEl();
		var bodyEl1 = win1.getBodyEl();
		$(bodyEl1).empty();
		$.post("customer_manage_find_province.do", {}, function(data) {
			win1.showAtEl(el, {
			   xAlign:"left",
			   yAlign:"below"
			});
			$.each(data, function(i, obj) {
				$(bodyEl1).append("</li><a href='javascript:loadC("+obj.id+", "+'"'+obj.pName+'"'+")' style='padding: 5px;'>"+obj.pName+"</a>");
			});
		}, "json");
		
 	}
 
 	// 通过省加载城市
 	var city = mini.get("city");
 	var cityVal = mini.get("city_val");
 	var win2 = mini.get("win2");
 	function loadC(p_id, p_name) {
 		var el = city.getEl();
		var bodyEl2 = win2.getBodyEl();
		$(bodyEl2).empty();
		$.post("customer_manage_find_city.do", {provinceId: p_id}, function(data) {
	 		provinceVal.setValue(p_id);
	 		province.setValue(p_name);
	 		win1.hide();
			win2.showAtEl(el, {
			   xAlign:"left",
			   yAlign:"below"
			});
			$.each(data, function(i, obj) {
				$(bodyEl2).append("<a href='javascript:loadD("+obj.id+", "+'"'+obj.cName+'"'+")' style='padding: 5px;'>"+obj.cName+"</a>");
				mini.parse();
			});
		}, "json");
 	}
 	
 	// 通过城市加载区县
 	var win3 = mini.get("win3");
 	var district = mini.get("district");
 	var districtVal = mini.get("district_val");
 	function loadD(c_id, c_name) {
 		var el = district.getEl();
 		var bodyEl3 = win3.getBodyEl();
 		$(bodyEl3).empty();
 		$.post("customer_manage_find_district.do", {cityId: c_id}, function(data) {
 			city.setValue(c_name);
 			cityVal.setValue(c_id);
 			win2.hide();
 			win3.showAtEl(el, {
 			   xAlign:"left",
 			   yAlign:"below"
 			});
 			$.each(data, function(i, obj) {
				$(bodyEl3).append("<a href='javascript:setD("+obj.id+", "+'"'+obj.dName+'"'+")' style='padding: 5px;'>"+obj.dName+"</a>");
				mini.parse();
			});
 		}, "json");
 	}
 	
 	// 设置区县
 	function setD(d_id, d_name) {
 		win3.hide();
 		districtVal.setValue(d_id);
 		district.setValue(d_name);
 	}
	
</script>